<template>
	<view class="jzWrap">
		<block v-if="isHasDataFlag">
			<view class="jzItem"
				v-for="(item,index) in parList"
				:key="index"
			>
				<view class="jzHead defBg">
					<image class="samePar" v-if="item.parentHeadImg == ''" :src="defHead"></image>
					<image class="samePar" :src="getUrl(item.parentHeadImg)" v-else></image>
				</view>
				<view class="jzInfo">
					<view class="infoItem">姓名：{{item.parentRealName}}</view>
					<view class="infoItem">账号：{{item.parentAccount}}</view>
					<view class="infoItem">性别：{{item.parentSex}}</view>
				</view>
			</view>
		</block>
		<template v-else-if="isHasDataFlag == false">
			<no-data></no-data>
		</template>
	</view>
</template>

<script>
	import { getMyParents } from '@/api/zhuxue'
	export default {
		data() {
			return {
				isHasDataFlag:null,
				parList:[]
			}
		},
		computed:{
			getUrl(){
				return function(url){
					if(url != undefined){
						return this.zhuXueServer + '/' + url
					}
				}
			}
		},
		onShow(){
			this.loadMyParents();
		},
		methods: {
			onNavigationBarButtonTap(e){
				if(e.index == 0){
					uni.navigateTo({
						url:'/pages/subIndex/myJz/jzApplyRec'
					})
				}
			},
			loadMyParents(){
				let field = { account:uni.getStorageSync('token') };
				let contentStr = this.crypto.encrypt(JSON.stringify( field )); 
				getMyParents({content:contentStr}).then(res=>{
					this.isHasDataFlag = true;
					this.parList = res.data.datas;
				}).catch(err=>{
					this.isHasDataFlag = false;
					//console.log(err)
				});
			}
		}
	}
</script>
<style lang="scss">
	page{
		background: $pss-bg-primary;
	}
</style>
<style lang="scss" scoped>
	.jzWrap{
		@include respTo(phone){
			padding: 30rpx;
		}
		@include respTo(pad){
			padding: 20rpx;
		}
		.jzItem{
			background: #fff;
			padding: 20rpx;
			display: flex;
			@include respTo(phone){
				margin-bottom: 30rpx;
			}
			@include respTo(pad){
				margin-bottom: 20rpx;
			}
			.jzInfo{
				flex: 1;
				display: flex;
				flex-direction: column;
				justify-content: center;
				.infoItem{
					color: $pss-text-color3;
					margin-bottom: 10rpx;
					@include respTo(phone){
						line-height: 50rpx;
						font-size: $font-size30;
					}
					@include respTo(pad){
						line-height: 30rpx;
						font-size: $padSize18;
					}
				}
			}
			.jzHead{
				flex-shrink: 0;
				margin-right: 15rpx;
				@include respTo(phone){
					width: 160rpx;
					height: 160rpx;
				}
				@include respTo(pad){
					width: 120rpx;
					height: 120rpx;
				}
			}
		}
	}
</style>
